<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr1 = [1, 2, 3]
      let arr2 = [4, 5, 6]

      //数组的concat方法：返回一个新的数组
      let arr3 = arr1.concat(arr2)
      console.log('concat', arr3) // [1, 2, 3, 4, 5, 6]
      console.log('arr1', arr1) // [1, 2, 3] 不变
      console.log('arr2', arr2) // [4, 5, 6] 不变

      // 用 apply方法
      console.log([].push.apply(arr1, arr2))
      //  arr1.push(...arr2)
      console.log(arr1) // [1, 2, 3, 4, 5, 6]
      console.log(arr2) // 不变

      //  这样调用的结果有问题,
      //  arr1.push(arr2)
      //  console.log(arr1) // [1, 2, 3, Array(3)]
      //  console.log(arr2) // 不变
    </script>
  </body>
</html>
